package com.shengqin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shengqin.entity.PlanRelationClasses;
import com.shengqin.mapper.PlanRelationClassesMapper;
import com.shengqin.service.IPlanRelationClassesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 计划关联学校年级班级 服务实现类
 * </p>
 *
 * @author Rui.Zhou
 * @since 2023-12-05
 */
@Service
public class PlanRelationClassesServiceImpl extends ServiceImpl<PlanRelationClassesMapper, PlanRelationClasses> implements IPlanRelationClassesService {



    @Override
    public List<PlanRelationClasses> listByPlanIds(List<Integer> planIds) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().in(PlanRelationClasses::getPlanId,planIds);
        return list(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listByPlanId(Integer planId) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        return list(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listByPlanIdAndSchoolId(Integer planId, Integer schoolId) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        if(schoolId != null){
            wrapper.lambda().eq(PlanRelationClasses::getShcoolId,schoolId);
        }
        return list(wrapper);
    }

    @Override
    public boolean removeByPlanId(Integer planId) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        return remove(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listBySchoolIds(List<String> schoolIds) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().in(PlanRelationClasses::getShcoolId,schoolIds);
        return list(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listByPlanIdAndSchoolIdAndClassesId(Integer planId, Integer schoolId, Integer classesId) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        wrapper.lambda().eq(PlanRelationClasses::getShcoolId,schoolId);
        wrapper.lambda().eq(PlanRelationClasses::getClassesId,classesId);
        return list(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listByPlanIdAndSchoolIds(Integer planId, Set<Integer> schoolIds) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        wrapper.lambda().in(PlanRelationClasses::getShcoolId,schoolIds);
        return list(wrapper);
    }

    @Override
    public List<PlanRelationClasses> listByPlanIdAndClassesIds(Integer planId, Collection<Integer> classesIds) {
        QueryWrapper<PlanRelationClasses> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(PlanRelationClasses::getPlanId,planId);
        wrapper.lambda().in(PlanRelationClasses::getClassesId,classesIds);
        return list(wrapper);
    }
}
